package cn.tedu.boot31.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
//此注解作用：相当于添加了@Controller和每一个里面的方法都添加ResponBody注解
public class AxiosController {
    @RequestMapping("/helloAxios")
    public String helloAxios(){
        return "服务器接收到了请求！";
    }
    @RequestMapping("/test01")
    public String test01(String info){
        return "接收到了："+info;
    }
    @RequestMapping("/bmi")
    public String bmi(float h,float w){
        //计算bmi的值
        float bmi=w/(h*h);
        String info =null;
        if (bmi<18.5){
            info ="兄弟你瘦了";
        }else if (bmi<24){
            info="体重正常";
        }else if (bmi<30){
            info="微胖";
        }else {
            info="肥胖";
        }
        return info;
    }
    @RequestMapping("/check")
    public String check(String username){
        if (username.equals("tom")){
            return "用户名已存在！";
        }else {
            return "用户名可用！";
        }
    }
}
